using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[DisallowMultipleComponent]
public class AimWeaponEvent : MonoBehaviour
{
    public event Action<AimWeaponEvent, AimWeaponEventArgs> OnWeaponAim;

    /// <summary>
    /// 触发瞄准武器事件。
    /// </summary>
    /// <param name="aimDirection">瞄准方向。</param>
    /// <param name="aimAngle">瞄准角度。</param>
    /// <param name="weaponAimAngle">武器瞄准角度。</param>
    /// <param name="weaponAimDirectionVector">武器瞄准方向向量。</param>
    public void CallAimWeaponEvent(AimDirection aimDirection, float aimAngle, float weaponAimAngle,
        Vector3 weaponAimDirectionVector)
    {
        // 调用委托，如果存在订阅者，则执行对应的事件处理方法
        // 传递当前实例和自定义事件参数
        OnWeaponAim?.Invoke(this,
            new AimWeaponEventArgs()
            {
                aimDirection = aimDirection, aimAngle = aimAngle, weaponAimAngle = weaponAimAngle,
                weaponAimDirectionVector = weaponAimDirectionVector
            });
    }

}

public class AimWeaponEventArgs : EventArgs
{
    public AimDirection aimDirection;
    public float aimAngle;
    public float weaponAimAngle;
    public Vector3 weaponAimDirectionVector;
}